//
//  ZJDCTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by ZJ on 2017/9/4.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ZJDCTableViewCell.h"

@interface ZJDCTableViewCell ()
/** 头像 */
@property (nonatomic, strong) UIImageView *headerImageView;
/** name */
@property (nonatomic, strong) UILabel *nameLabel;
/** 下划线 */
@property (nonatomic, strong) UILabel *underLabel;
@end

@implementation ZJDCTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.headerImageView];
        [self.contentView addSubview:self.nameLabel];
        [self.contentView addSubview:self.underLabel];
        
        self.headerImageView.sd_layout
        .leftSpaceToView(self.contentView, 12 * [UIScreen zj_screenWScale])
        .topSpaceToView(self.contentView, 7.5 * [UIScreen zj_screenHScale])
        .heightIs(45 * [UIScreen zj_screenHScale])
        .widthEqualToHeight();
        
        self.headerImageView.layer.cornerRadius = 35 / 2 * [UIScreen zj_screenHScale];
        
        self.nameLabel.sd_layout
        .topSpaceToView(self.contentView, 0)
        .leftSpaceToView(self.headerImageView, 8 * [UIScreen zj_screenWScale])
        .rightSpaceToView(self.contentView, 12 * [UIScreen zj_screenWScale])
        .bottomSpaceToView(self.contentView, 0);
        
        self.underLabel.sd_layout
        .bottomSpaceToView(self.contentView, 0)
        .leftSpaceToView(self.contentView, 0)
        .rightSpaceToView(self.contentView, 0)
        .heightIs(1);
        
    }
    return self;
}


#pragma mark - Setter
- (void)setModel:(LPJoinPersonListModel *)model{
    _model = model;
    self.nameLabel.text = model.USER_NAME;
    [self.headerImageView sd_setImageWithURL:CREATEURL(model.PHOTO_THUMBURL) placeholderImage:PlaceholderHeaderImage];
}

#pragma mark - Getters
- (UIImageView *)headerImageView{
    if (_headerImageView == nil){
        _headerImageView = [UIImageView new];
        
    }
    return _headerImageView;
}

- (UILabel *)nameLabel{
    if (_nameLabel == nil){
        _nameLabel = [UILabel new];
        _nameLabel.textColor = [UIColor textBlackColor];
        _nameLabel.font = [UIFont titleTextFont];
    }
    return _nameLabel;
}
- (UILabel *)underLabel{
    if (_underLabel == nil){
        _underLabel = [UILabel new];
        _underLabel.backgroundColor = [UIColor viewBGGrayColor];
    }
    return _underLabel;
}
@end



